package hou.just4fun.SeekGirlFriend.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;

import hou.just4fun.SeekGirlFriend.model.Person;

/**
 * @author houweitao
 * @date 2016年5月13日下午5:21:32
 */

public class Satisfied {

	public static int rank(Person person) {
		if (person.getLover() == null)
			return -1;

		List<Integer> scores = new ArrayList<>();
		for (Entry<String, Integer> entry : person.getLoverScoreMap().entrySet()) {
			scores.add(entry.getValue());
		}
		Collections.sort(scores);
		int pos = scores.lastIndexOf(person.getLoverScoreMap().get(person.getLover().getName()));
		return person.getLoverScoreMap().size() - pos;
	}
}
